package com.example.teamilkmall.controller;

import com.example.teamilkmall.controller.vo.ResultVO;
import com.example.teamilkmall.entity.OrderInfo;
import com.example.teamilkmall.service.OrderInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2025-01-07
 */
@RestController
@RequestMapping("/orderInfo")
public class OrderInfoController extends BaseController{
    
    private final OrderInfoService orderInfoService;

    public OrderInfoController(OrderInfoService orderInfoService) {
        this.orderInfoService = orderInfoService;
    }

    @GetMapping("/listOrderInfo")
    public ResultVO<PageInfo<OrderInfo>> listOrders(Integer limit, Integer page, Integer id){
        PageInfo<OrderInfo> pageInfo = orderInfoService.listOrderInfo(limit, page, id);
        return success(pageInfo);
    }

    @PostMapping("/updateOrderInfo")
    public ResultVO updateOrders(OrderInfo orders){
        orderInfoService.updateOrderInfo(orders);
        return success();
    }

    @PostMapping("/deloneOrderInfo")
    public ResultVO deloneOrders(Integer id){
        orderInfoService.deloneOrderInfo(id);
        return success();
    }

    @PostMapping("/addOrderInfo")
    public ResultVO addOrders(OrderInfo orders){
        orderInfoService.addOrderInfo(orders);
        return success();
    }

    @PostMapping("/listOrderInfoAll")
    public ResultVO<List<OrderInfo>> getOrdersList(){
        return success(orderInfoService.getListOrderInfo());
    }
}
